#ifndef __PALYER_FRIEND_H__
#define __PALYER_FRIEND_H__

class PacketDecoder;
class PlayerTeam;

class PlayerFriend:public PlayerTeam
{

public:
	PlayerFriend(PlayerId stPlayerId);
	virtual ~PlayerFriend();

	bool addFriend(Int32 char_id,Int32 relation = FriendInfo::FRIEND_TYPE_NORMAL);
	bool addFriend(Int32 nCharId,std::string szCharName,Int32 nLevel,Int32 nRace,Int32 nGender,Int32 nValue,Int32 relation = FriendInfo::FRIEND_TYPE_NORMAL);
	void removeFriend(Int32 char_id);
	bool addFriendTmp(Int32 char_id);
	void removeFriendTmp(Int32 char_id);
	bool addFriendFavorite(SimpleCharInfo& simpleCharInfo);
	bool addFriendBoring(SimpleCharInfo& simpleCharInfo);
	void removeFriendsAllFavorite();
	void removeFriendsAllBoring();
	UInt32 getFriendSize();
	UInt32 getTmpFriendSize();
	UInt32 getFavoriteFriendSize();
	UInt32 getBoringFriendSize();
	bool hasFriend(Int32 char_id,Int32 relation = FriendInfo::FRIEND_TYPE_NORMAL);
	bool hasFriendTmp(Int32 char_id);
	void addFriendLove(Int32 char_id,Int32 nLoveChange);
	Int32 getFriendLove(Int32 char_id);
	void decodeFriends();
	void encodeFriends();

	UInt32			m_nTimerSendFriends;
	virtual void PrepareSendFriends(){if(m_nTimerSendFriends == 0) m_nTimerSendFriends = CreateTimer(boost::bind(&PlayerFriend::OnTimerSendFriends, this,_1),100);}
	void OnTimerSendFriends(UInt32 nTimerId);

	void sendFriends();
	void sendFriendsFavorite();
	void sendFriendsBoring();
	void sendFriendsTmp();
	void sendOfflineMessage();
	void sendFriendTrends();
	void sendFriendUpdate(Int32 char_id,Int32 state = FriendInfo::FRIEND_STATE_ONLINE);
	void popOneTmpFriend();

	FriendInfo* getFriendInfo(Int32 char_id);
	FriendInfo* getFriendFavoriteInfo(Int32 char_id);
	FriendInfo* getFriendBoringInfo(Int32 char_id);
	FriendInfo* getFriendTmpInfo(Int32 char_id);

	void updateFriendsFavorite();
	void updateFriendsBoring();
private:
	std::map<Int32,FriendInfo>	m_arFriends;
	std::map<Int32,FriendInfo>	m_arFriendsFavorite;
	std::map<Int32,FriendInfo>	m_arFriendsBoring;
	std::map<Int32,FriendInfo>	m_arFriendsTmp;

};
#pragma pack()
#endif